const columns = (FormModal, expand, onRemove, namespace, n) => {
  return [
      {
        type: 'expand',
        width: 50,
        render: (h, {row}) => {
            if(row.children.length > 0) {
              return h(expand, {
                props: {
                    data: row.children,
                    modal: FormModal,
                    expand,
                    onRemove,
                    namespace,
                    n: n + 1
                }
              })
            } else {
              return null
            }
        }
      },
      {
          title: '资源名称',
          key: 'name',
          width: 180,
          render:(h, {row}) => {
            return h('p', {
              style: {
                textIndent:n * 20 + 'px'
              }
            }, row.name);
          }
      },
      {
          title: '资源标识',
          key: 'identity',
          width: 180
      },
      {
        title: '资源链接',
        key: 'url',
        width: 180
      },
      {
          title: '拥有权限',
          // width:180,
          key: 'permissionText'
      },
      {
          title: '创建日期',
          key: 'ctime',
          width: 180
      },
      {
          title: '维护日期',
          key: 'mtime',
          width: 180
      }, {
          title: '操作',
          key: 'operation',
          width: 170,
          render: (h, { row, column, index }) => {
              return h('div', [
                  h(FormModal, {
                    props: {
                        title: '新增资源',
                        record: {id:row.id, pids:row.pids},
                        option: 'create',
                        namespace,
                        perm: 'resource:create',
                        type: 'text',
                        size: 'small'
                    }
                  }, '新增'),
                  h(FormModal, {
                      props: {
                          title: '编辑权限',
                          record: row,
                          option: 'update',
                          namespace,
                          perm: 'resource:update',
                          type: 'text',
                          size: 'small'
                      }
                  }, '编辑'),
                  h('IButton', {
                      on: {
                          click: () => onRemove(row.id)
                      },
                      props: {
                          type: 'text',
                          size: 'small',
                          perm: 'resource:remove',
                          click: true
                      },
                  }, '删除')
              ]);
          }
      }
  ]
}
export default columns;
